<?php include(TPL_PATH . '/admin/inc_header.php'); ?>
<?php include(TPL_PATH . '/admin/inc_top.php'); ?>

<link rel="stylesheet" href="<?php p(HTTP_URL) ?>/statics/kindeditor/themes/default/default.css" />
<script type="text/javascript" src="<?php p(HTTP_URL) ?>/statics/kindeditor/kindeditor.js"></script>
<script type="text/javascript">

$(document).ready(function() {
	$('.cls_order').tooltip({'placement':'right'});
	var btnUp = KindEditor.uploadbutton({
		'button' : $('#id_upbtn')[0],
		'fieldName' : 'img_file',
		'url' : '<?php p(HTTP_URL) ?>/index.php?m=admin&c=file&a=upload',
		'afterUpload' : function(data) {
			if (data.error === 0) {
				show_thumb(data.url);
			} else {
				alert(data.message);
			}
		}
	});
	btnUp.fileBox.change(function(e) {
		btnUp.submit();
	});
});

function show_thumb(path) {
	$('#id_new_a').attr('href', '<?php p(HTTP_URL) ?>' + path + '?' + (new Date).getTime());
	$('#id_new_path').val(path);
	var img = $('#id_new_img');
	img.attr('src', '<?php p(HTTP_URL) ?>' + path + '?' + (new Date).getTime());
}

</script>

<form method="post" action="<?php p(HTTP_URL) ?>/index.php?m=admin&c=slide">

    <?php if (!empty($strMsg)) { ?>
	<div class="alert alert-error">
		<button type="button" class="close" data-dismiss="alert">&times;</button>
		<?php p($strMsg) ?>
	</div>
	<?php } elseif (!empty($strOk)) { ?>
	<div class="alert alert-success">
		<button type="button" class="close" data-dismiss="alert">&times;</button>
		<?php p($strOk) ?>
	</div>
	<?php } ?>

    <table class="table table-bordered table-condensed" width="100%" cellspacing="0" cellpadding="0">
    	<tr>
    		<td colspan="7">
    			<ul class="breadcrumb" style="margin:0px;">
    				<li>焦点图管理</li>
    			</ul>
    		</td>
    	</tr>
    	<tr>
    		<th style="width:230px;">图片</th>
    		<th>说明</th>
    		<th>链接</th>
    		<th style="width:75px;">排序</th>
    		<th style="width:31px;">可用</th>
    		<th style="width:55px;">保存</th>
    		<th style="width:55px;">删除</th>
    	</tr>
    	
    	<?php foreach ($arrList as $arrTemp) { ?>
    	
    	<tr>
    		<td>
    			<img alt="" src="<?php p(HTTP_URL . $arrTemp['path']) ?>" style="width:220px; height:150px;" /><br />
        		<a class="btn" target="_blank" href="<?php p(HTTP_URL . $arrTemp['path']) ?>">原图</a>
    		</td>
    		<td>
    			<input type="text" name="<?php p($arrTemp['id']) ?>_title" class="input-xlarge" value="<?php p($arrTemp['title']) ?>" />
    		</td>
    		<td>
    			<input type="text" name="<?php p($arrTemp['id']) ?>_link" class="input-xlarge" value="<?php p($arrTemp['link']) ?>" />
    		</td>
    		<td>
    			<input type="text" name="<?php p($arrTemp['id']) ?>_list_order" title="较小排在前" class="cls_order input-mini" value="<?php p($arrTemp['list_order']) ?>" />
    		</td>
    		<td>
    			<input type="checkbox" name="<?php p($arrTemp['id']) ?>_rec_status" <?php $arrTemp['rec_status'] ? p('checked="checked"') : p('') ?> value="1" />
    		</td>
    		<td>
    			<input type="submit" name="<?php p($arrTemp['id']) ?>_update" class="btn" value="修改" />
    		</td>
    		<td>
    			<input type="submit" name="<?php p($arrTemp['id']) ?>_delete" class="btn" value="删除" />
    		</td>
    	</tr>
    	
    	<?php } ?>
    	<tr>
    		<td>
    			<input type="hidden" id="id_new_path" name="new_path" value="" />
    			<img alt="" id="id_new_img" src="<?php p(HTTP_URL . '/uploads/no_image.jpg') ?>" style="width:220px; height:150px;" /><br />
    			<a class="btn" id="id_new_a" target="_blank" href="<?php p(HTTP_URL . '/uploads/no_image.jpg') ?>">原图</a>
        		<input type="button" id="id_upbtn" value="上传" />
    		</td>
    		<td>
    			<input type="text" name="new_title" class="input-xlarge" />
    		</td>
    		<td>
    			<input type="text" name="new_link" class="input-xlarge" />
    		</td>
    		<td>
    			<input type="text" name="new_list_order" title="较小排在前" class="cls_order input-mini" />
    		</td>
    		<td>
    			<input type="checkbox" name="new_rec_status" checked="checked" value="1" />
    		</td>
    		<td colspan="2">
    			<input type="submit" name="add" class="btn btn-primary" value="添加" />
    		</td>
    	</tr>

    </table>
</form>

<?php include(TPL_PATH . '/admin/inc_bottom.php'); ?>
<?php include(TPL_PATH . '/admin/inc_footer.php'); ?>